//
//  LMSectionView.m
//  Perking
//
//  Created by longmin on 16/9/10.
//  Copyright © 2016年 tim. All rights reserved.
//

#import "LMSectionView.h"

@interface LMSectionView()

@property(nonatomic, strong) UILabel *titleLabel;

@end

@implementation LMSectionView

#pragma mark - 生命周期

-(instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.titleLabel];
    }
    return self;
}

#pragma mark - set方法和get方法

-(UILabel *)titleLabel {
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc] init];
    }
    return _titleLabel;
}

-(void)setTitle:(NSString *)title {
    self.titleLabel.text = title;
}

-(NSString *)title {
    return self.titleLabel.text;
}

#pragma mark - IBActions
#pragma mark - Public

+(instancetype)sectionViewWithHeight:(CGFloat)height font:(UIFont *)font color:(UIColor *)color title:(NSString *)title {
    
    LMSectionView *sectionView= [[LMSectionView alloc] init];
    sectionView.height = height;
    sectionView.width = __kScreenWidth;
    sectionView.titleLabel.font = font;
    sectionView.titleLabel.text = title;
    sectionView.titleLabel.textColor = color;
    return sectionView;
}

#pragma mark - Private
#pragma mark - 数据源和代理方法
#pragma mark - UIView -> 下面放继承自UIView的方法

-(void)layoutSubviews {
    [super layoutSubviews];
    
    [self.titleLabel sizeToFit];
    self.titleLabel.left = self.textLeft ? self.textLeft : MK_PADDING_30;
    self.titleLabel.bottom = self.height - 8;
    
//    self.height = MK_PADDING_30 + MK_PADDING_20 + self.titleLabel.height;
    
}

@end
